package com.niit.drugsmanager.service.Impl;

import com.niit.drugsmanager.entity.NoticeStatus;
import com.niit.drugsmanager.repository.NoticeStatusRepository;
import com.niit.drugsmanager.service.NoticeStatusService;
import jakarta.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Transactional
public class NoticeStatusServiceImpl implements NoticeStatusService {
    @Autowired
    private NoticeStatusRepository noticeStatusRepository;

    @Override
    public List<NoticeStatus> getAllNoticeStatus() {
        return noticeStatusRepository.findAll();
    }

    @Override
    public NoticeStatus updateNoticeStatus(NoticeStatus noticeStatus) {
        return noticeStatusRepository.save(noticeStatus);
    }

    @Override
    public List<NoticeStatus> getNoticeStatusByUserId(Long userId) {
        return noticeStatusRepository.findNoticeStatusesByUid(userId);
    }

    @Override
    public NoticeStatus addNoticeStatus(NoticeStatus noticeStatus) {
        return noticeStatusRepository.save(noticeStatus);
    }

    @Override
    public void deleteNoticeStatusByNid(Long nid) {
        noticeStatusRepository.deleteNoticeStatusesByNid(nid);
    }
}
